// This file was decompiled using SASCM.ini published on 2021-07-05
{$CLEO .cs}
{$USE CLEO+}
{$USE Audio}
{$USE newOpcodes}
{$USE ini}

0000: NOP 

script_name "StAxe"

// By ArtemQa146

wait 500

:LoadedModels
wait 500
0AF0: 1@ = read_int_from_ini_file "cleo\StreetCleaners.ini" section "Models" key "Loaded4"
if
1@ == 1
jf @LoadedModels
1@ = 0 
0AF1: write_int 1@ to_ini_file "cleo\StreetCleaners.ini" section "Models" key "Loaded4"

0AF0: 0@ = read_int_from_ini_file "cleo\Busy Pedestrians.ini" section "Settings" key "Street Cleaners"
if
    0@ == 0
then
    0A93: terminate_this_custom_script
end

0AF0: 6@ = read_int_from_ini_file "cleo\Busy Pedestrians.ini" section "Street Cleaners" key "Ped ID Axe"
0AF0: 30@ = read_int_from_ini_file "cleo\StreetCleaners.ini" section "Models" key "StumpWood"
0AF0: 31@ = read_int_from_ini_file "cleo\StreetCleaners.ini" section "Models" key "Axe"

if
    6@ <= 0
then
    6@ = 158
end

// 1@ actor
// 0@ render
// 5@ particle
// 6@ Ped ID from ini

:Axe
wait 150
if 
   Player.Defined($PLAYER_CHAR)
jf @Axe
if and
$ACTIVE_INTERIOR == 0  
$ONMISSION == 0 
jf @Axe
0D59: get_current_weather_to 3@
0E40: get_current_hour 2@
if and
not 3@ == 8 // not weather rain 
not 3@ == 16 // not weather rain 2
2@ >= 6
18 >= 2@
jf @Axe

// LS

:Axe_Coords_1 
if and
0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -742.9681 -110.64 66.9765 radius 100.0
not locate_char_distance_to_coordinates $PLAYER_ACTOR pos -742.9681 -110.64 66.9765 radius 50.0
jf @Axe_Coords_2 
// coords to walk 
10@ = -742.9681
11@ = -110.64
12@ = 65.9765
13@ = 334.4105
jump @Axe_Start

:Axe_Coords_2 
if and
0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -475.9353 -202.3517 78.3045 radius 100.0
not locate_char_distance_to_coordinates $PLAYER_ACTOR pos -475.9353 -202.3517 78.3045 radius 50.0
jf @Axe_Coords_3 
// coords to walk 
10@ = -475.9353
11@ = -202.3517
12@ = 77.3045
13@ = 30.741
jump @Axe_Start

:Axe_Coords_3 
if and
0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 806.4108 348.8607 19.8539 radius 100.0
not locate_char_distance_to_coordinates $PLAYER_ACTOR pos 806.4108 348.8607 19.8539 radius 50.0
jf @Axe_Coords_4
// coords to walk 
10@ = 806.4108
11@ = 348.8607
12@ = 18.8539
13@ = 110.218
jump @Axe_Start

:Axe_Coords_4 
if and
0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1206.6005 -2337.0996 14.3833 radius 100.0
not locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1206.6005 -2337.0996 14.3833 radius 50.0
jf @Axe_Coords_5
// coords to walk 
10@ = 1206.6005
11@ = -2337.0996
12@ = 13.3833
13@ = 330.36
jump @Axe_Start

:Axe_Coords_5
wait 100
if and
0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -2055.7397 -2370.9043 30.6318 radius 100.0
not locate_char_distance_to_coordinates $PLAYER_ACTOR pos -2055.7397 -2370.9043 30.6318 radius 50.0
jf @Axe_Coords_6
// coords to walk 
10@ = -2055.7397
11@ = -2370.9043
12@ = 30.6318
13@ = 321.4445
jump @Axe_Start

:Axe_Coords_6
if and
0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -1070.4207 -1309.4867 129.2187 radius 100.0
not locate_char_distance_to_coordinates $PLAYER_ACTOR pos -1070.4207 -1309.4867 129.2187 radius 50.0
jf @Axe_Coords_7
// coords to walk 
10@ = -1070.4207
11@ = -1309.4867
12@ = 128.2187
13@ = 2.564
jump @Axe_Start

:Axe_Coords_7
if and
0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -1362.4501 2032.9926 52.5161 radius 100.0
not locate_char_distance_to_coordinates $PLAYER_ACTOR pos -1362.4501 2032.9926 52.5161 radius 50.0
jf @Axe_Coords_8
// coords to walk 
10@ = -1362.4501
11@ = 2032.9926
12@ = 51.5161
13@ = 270.67
jump @Axe_Start

:Axe_Coords_8
wait 100
if and
0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1505.61 362.1606 19.1869 radius 100.0
not locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1505.61 362.1606 19.1869 radius 50.0
jf @Axe_Coords_9
// coords to walk
10@ = 1505.61 
11@ = 362.1606
12@ = 19.1869
13@ = 48.5228
jump @Axe_Start

:Axe_Coords_9
if and
0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 299.0287 49.6804 2.6935 radius 100.0
not locate_char_distance_to_coordinates $PLAYER_ACTOR pos 299.0287 49.6804 2.6935 radius 50.0
jf @Axe_Coords_10
// coords to walk
10@ = 299.0287 
11@ = 49.6804
12@ = 2.6935
13@ = 46.5095
jump @Axe_Start

:Axe_Coords_10
if and
0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -400.3968 -415.3801 16.2109 radius 100.0
not locate_char_distance_to_coordinates $PLAYER_ACTOR pos -400.3968 -415.3801 16.2109 radius 50.0
jf @Axe
// coords to walk
10@ =-400.3968 
11@ = -415.3801
12@ = 16.2109
13@ =277.1255
jump @Axe_Start


:Axe_Start 
Model.Load(6@)
model.Load(843)
model.Load(342)
model.Load(1463)
if
    not model.Available(6@)
then
    repeat
    wait 0
    model.Load(6@)
    until model.Available(6@)
end
if
    not model.Available(843)
then
    repeat
    wait 0
    model.Load(843)
    until model.Available(843)
end
if
    not model.Available(342)
then
    repeat
    wait 0
    model.Load(342)
    until model.Available(342)
end
if
    not model.Available(1463)
then
    repeat
    wait 0
    model.Load(1463)
    until model.Available(1463)
end
038B: load_requested_models 

repeat
wait 0
04ED: load_animation  "PedEventsMod"
until 04EE:   animation "PedEventsMod" loaded


Actor.Create(1@, 21, 6@, 10@, 11@, 12@)   
Actor.Angle(1@) = 13@
0E24: fix_char 1@ ground 1 brightness 1 and_fade_in 0
04C4: store_coords_to 2@ 3@ 4@ from_actor 1@ with_offset -1.2 1.2 -1.0
0E01: create_object_no_save 843 at 2@ 3@ 4@ offset 0 ground 1 to 8@
0177: set_object 8@ Z_angle_to 13@
04C4: store_coords_to 2@ 3@ 4@ from_actor 1@ with_offset 0.1 1.25 -0.7
0E01: create_object_no_save 342 at 2@ 3@ 4@ offset 0 ground 0 to 20@ 
0F04: create_render_object_to_object_from_special 20@ special_model 30@ offset 0 0 0 rotation 0 0 0 store_to 22@
0382: set_object 20@ collision_detection 0
0177: set_object 20@ Z_angle_to 13@
0176: 13@ = object 20@ Z_angle
000B: 13@ += 180.0
04C4: store_coords_to 2@ 3@ 4@ from_actor 1@ with_offset 0.18 1.25 -0.7
0E01: create_object_no_save 342 at 2@ 3@ 4@ offset 0 ground 0 to 21@ 
0F04: create_render_object_to_object_from_special 21@ special_model 30@ offset 0 0 0 rotation 0 0 0 store_to 23@
0382: set_object 21@ collision_detection 0
0177: set_object 21@ Z_angle_to 13@
000B: 13@ += 180.0

0400: store_coords_to 2@ 3@ 4@ from_object 20@ with_offset 0.0 0.0 0.0
0E01: create_object_no_save 342 at 2@ 3@ 4@ offset 0 ground 0 to 27@
0F04: create_render_object_to_object_from_special 27@ special_model 30@ offset 0 0 0 rotation 0 0 0 store_to 24@
0382: set_object 27@ collision_detection 0
0177: set_object 27@ Z_angle_to 13@
0176: 13@ = object 27@ Z_angle
000B: 13@ += 180.0
0400: store_coords_to 2@ 3@ 4@ from_object 21@ with_offset 0.0 0.0 0.0
0E01: create_object_no_save 342 at 2@ 3@ 4@ offset 0 ground 0 to 28@
0F04: create_render_object_to_object_from_special 28@ special_model 30@ offset 0 0 0 rotation 0 0 0 store_to 29@
0382: set_object 28@ collision_detection 0
0177: set_object 28@ Z_angle_to 13@

04C4: store_coords_to 15@ 16@ 17@ from_actor 1@ with_offset 0.12 1.25 -0.6
064B: 5@ = create_particle "vent" at 15@ 16@ 17@ type 1
08D2: object 20@ scale_model 0
08D2: object 21@ scale_model 0
08D2: object 27@ scale_model 0
08D2: object 28@ scale_model 0
0812: AS_actor 1@ perform_animation "AxeLoop" IFP "PedEventsMod" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 1 time -1
0208: 18@ = random_float_in_ranges 5.0 10.0
18@ *= -1.0
25@ = 0
26@ = 0
0F02:  1@ special_model 31@ bone 24 offset 0 0 0 rotation 0 0 0 scale 0@ // bone 34 left hand, 24 right hand, 9 had, 3 tors
0E30: set_render_object_auto_hide 0@ dead 1 weapon 1 car 1 
0AC1: 7@ = load_audio_stream_with_3d_support "SQ/Axe.mp3" // IF and SET
0AC4: link_3d_audio_stream 7@ to_actor 1@

0400: store_coords_to 2@ 3@ 4@ from_object 21@ with_offset -1.8 0.5 1.0
0E01: create_object_no_save 1463 at 2@ 3@ 4@ offset 0 ground 1 to 19@
0176: 13@ = object 27@ Z_angle
13@ += 80.0
0177: set_object 19@ Z_angle_to 13@
08D2: object 19@ scale_model 0.0
0382: set_object 19@ collision_detection 0

model.Destroy(342)
model.Destroy(843)
model.Destroy(1463)
Model.destroy(6@)

14@ = 0

while true
wait 0
    if
        056D:   actor 1@ defined
    then
        if and
            0EE4: locate_char_distance_to_char $PLAYER_ACTOR char 1@ radius 150.0
            $ACTIVE_INTERIOR == 0
        then
        
            if or
                Actor.Animation(1@) == "AxeLoop"
                Actor.Animation(1@) == "AxeTired"
            then
                if
                    Actor.Animation(1@) == "AxeLoop"
                then
                    0613: 4@ = actor 1@ animation "AxeLoop" time
                    25@ = 1
                end
                if
                    Actor.Animation(1@) == "AxeTired"
                then
                    0613: 4@ = actor 1@ animation "AxeTired" time
                    25@ = 2
                end

                if
                    Actor.Animation(1@) == "AxeLoop"
                then
                    if and
                        0EE4: locate_char_distance_to_char $PLAYER_ACTOR char 1@ radius 20.0
                        4@ >= 0.30
                        4@ <= 0.40
                    then
                        0EC0: add_fx_system_particle 5@ coord 15@ 16@ 17@ vel 0 0 0 size 1.0 brightness 0.0 rgba 1.0 0.6 0.4 0.4 lastFactor 0.3
                    end

                    if and
                        4@ >= 0.36
                        4@ <= 0.46
                    then
                        if and
                            26@ == 0
                            0EE4: locate_char_distance_to_char $PLAYER_ACTOR char 1@ radius 20.0
                        then
                            0AAD: set_audio_stream 7@ state 1
                            0ABC: set_audio_stream 7@ volume 0.4
                            26@ = 1
                        end
                        0E36: set_render_object_rotation 22@ 0 18@ 0
                        0E36: set_render_object_rotation 23@ 0 18@ 0
                        0E36: set_render_object_rotation 24@ 0 18@ 0
                        0E36: set_render_object_rotation 29@ 0 18@ 0
                    end
                    
                    if and
                        4@ >= 0.80
                        4@ <= 0.90
                        0EE4: locate_char_distance_to_char $PLAYER_ACTOR char 1@ radius 20.0
                    then
                        0EC0: add_fx_system_particle 5@ coord 15@ 16@ 17@ vel 0 0 0 size 1.0 brightness 0.0 rgba 1.0 0.6 0.4 0.4 lastFactor 0.3
                    end

                    if and
                        4@ >= 0.85
                        4@ <= 0.95
                    then
                        if and
                            26@ == 1
                            0EE4: locate_char_distance_to_char $PLAYER_ACTOR char 1@ radius 20.0
                        then
                            0AAD: set_audio_stream 7@ state 1
                            0ABC: set_audio_stream 7@ volume 0.4
                            26@ = 0
                        end
                        0E36: set_render_object_rotation 22@ 10.0 -80.0 0
                        0E36: set_render_object_rotation 23@ -10.0 -80.0 0
                        0E36: set_render_object_rotation 24@ 10.0 -80.0 0
                        0E36: set_render_object_rotation 29@ -10.0 -80.0 0
                    end
                end

                // if animation ended, walk another position
                if
                    4@ >= 0.95
                then
                    26@ = 0
                    0208: 18@ = random_float_in_ranges 5.0 10.0
                    18@ *= -1.0
                    0E36: set_render_object_rotation 22@ 0 0 0
                    0E36: set_render_object_rotation 23@ 0 0 0
                    0E36: set_render_object_rotation 24@ 0 0 0
                    0E36: set_render_object_rotation 29@ 0 0 0
                    if
                        25@ == 1
                    then
                        0E31: set_render_object_visible 22@ 0
                        0E31: set_render_object_visible 23@ 0
                        0E31: set_render_object_visible 24@ 0
                        0E31: set_render_object_visible 29@ 0
                        0812: AS_actor 1@ perform_animation "AxeTired" IFP "PedEventsMod" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 1 time -1
                        25@ = 0
                        if
                            0EE4: locate_char_distance_to_char $PLAYER_ACTOR char 1@ radius 10.0
                        then
                            14@ += 1
                            if and
                                03CA:   object 19@ exists
                                14@ == 3
                            then
                                08D2: object 19@ scale_model 0.7
                                0382: set_object 19@ collision_detection 1
                            end
                        end
                        wait 100
                        continue
                    end
                    if
                        25@ == 2
                    then
                        0E31: set_render_object_visible 22@ 1
                        0E31: set_render_object_visible 23@ 1
                        0E31: set_render_object_visible 24@ 1
                        0E31: set_render_object_visible 29@ 1
                        0812: AS_actor 1@ perform_animation "AxeLoop" IFP "PedEventsMod" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 1 time -1
                        25@ = 0
                        wait 100
                        continue
                    end
                end
            end

            0D59: get_current_weather_to 3@
            0E40: get_current_hour 4@
            080E: get_actor 1@ ped_event_to 2@
            if or
                0118:   actor 1@ dead
                3@ == 8 // not weather rain
                3@ == 16 // not weather rain 2
                4@ >= 19 // timeout
                2@ == 9 // ped damaged
                2@ == 49 // shoot close ped
            then
                if
                    0EE4: locate_char_distance_to_char $PLAYER_ACTOR char 1@ radius 50.0
                then
                    gosub @Remove_2
                else
                    gosub @Remove
                end
                jump @Axe
            end
            
            080E: get_actor 1@ ped_event_to 2@
            if or
                2@ == 15
                2@ == 31
                2@ == 59
            then
                if
                    0EE4: locate_char_distance_to_char $PLAYER_ACTOR char 1@ radius 50.0
                then
                    gosub @Remove_2
                else
                    gosub @Remove
                end
                jump @Axe
            end
            
            
            //    
            if
                0457:   player $PLAYER_CHAR aiming_at_actor 1@
            then
                0E83: get_current_char_weaponinfo $PLAYER_ACTOR store_to 2@
                0E89: get_weaponinfo_fire_type 2@ store_to 3@ //     
                if or
                    3@ == 1 //  
                    3@ == 3 //   (  ..)
                then
                    if
                    0EE4: locate_char_distance_to_char $PLAYER_ACTOR char 1@ radius 50.0
                    then
                        gosub @Remove_2
                    else
                        gosub @Remove
                    end
                    jump @Axe
                end
            end
            
            
        else
            gosub @Remove
            wait 1000
            jump @Axe
        end
    else
        gosub @Remove
        wait 1000
        jump @Axe
    end
end


:Remove
if 03CA:   object 8@ exists
then 0108: destroy_object 8@
end
if 03CA:   object 19@ exists
then 0108: destroy_object 19@
end
if 03CA:   object 20@ exists
then 0108: destroy_object 20@
end
if 03CA:   object 21@ exists
then 0108: destroy_object 21@
end
if 03CA:   object 27@ exists
then 0108: destroy_object 27@
end
if 03CA:   object 28@ exists
then 0108: destroy_object 28@
end
0AAE: remove_audio_stream 7@
0650: destroy_particle 5@
if 056D:   actor 1@ defined
then 009B: destroy_actor 1@
end
04EF: release_animation "PedEventsMod"
return

:Remove_2
if 03CA:   object 8@ exists
then 01C4: remove_references_to_object 8@ // This object will now disappear when the player looks away
end
if 03CA:   object 19@ exists
then 01C4: remove_references_to_object 19@ // This object will now disappear when the player looks away
end
if 03CA:   object 20@ exists
then 01C4: remove_references_to_object 20@ // This object will now disappear when the player looks away
end
if 03CA:   object 21@ exists
then 01C4: remove_references_to_object 21@ // This object will now disappear when the player looks away
end
if 03CA:   object 27@ exists
then 01C4: remove_references_to_object 27@ // This object will now disappear when the player looks away
end
if 03CA:   object 28@ exists
then 01C4: remove_references_to_object 28@ // This object will now disappear when the player looks away
end
0AAE: remove_audio_stream 7@
0650: destroy_particle 5@
if 056D:   actor 1@ defined
then 01C2: remove_references_to_actor 1@ // Like turning an actor into a random pedestrian
end
04EF: release_animation "PedEventsMod"
return

// By ArtemQa146